<?php
/**
 * 周排行榜,五分钟变化一次
 * WeekSyncRankList
 */
class WeekSyncRankList extends APIBase {
		
		public $tag = "WeekSyncRankList";
		public $isLogin = false;
		
		public function before() {
			$this->initCacheRedis();
			return true;
		}

		public function logic() {
			
			$hkeys = count($this->cache_redis->keys("hWeekCharismaSyncRank:*"));
			for ($i=0; $i< $hkeys; $i++) 
			{
				$rank = $this->cache_redis->hMGet("hWeekCharismaSyncRank:{$i}", array("num","uid", "name", "charisma"));
				if ($rank)
				{	
					$rank["uid"] = (int)$rank["uid"];					
					$rank["num"] = (int)$rank["num"];
					$rank["name"] = (string)$rank["name"];
					$rank["charisma"] = (int)$rank["charisma"];
					$charisma_ranks[] = $rank;
				}
			}
			$hkeys = count($this->cache_redis->keys("hWeekActivitySyncRank:*"));
			for ($i=0; $i< $hkeys; $i++)
			{
				$rank = $this->cache_redis->hMGet("hWeekActivitySyncRank:{$i}", array("num","uid", "name", "activity"));
				if ($rank)
				{
					$rank["uid"] = (int)$rank["uid"];
					$rank["num"] = (int)$rank["num"];
					$rank["name"] = (string)$rank["name"];
					$rank["activity"] = (int)$rank["activity"];
					$activity_ranks[] = $rank;
				}
			}
			
			$this->returnData(array('charisma_ranks' => $charisma_ranks,'activity_ranks' => $activity_ranks));
		}
		
    	public function after() {
			$this->deinitCacheRedis();
		}
    }
?>
